﻿package com.pandemicode.framework.utils {
	/**
	* @author Michael Lawrence
	* @version 1.0.	*/
	public class Time {
		/**
		 * A series of methods to help in converting time.
		 */
		public function Time() { }
		
		/**
		 * Converts the specified milliseconds into an appropriate time string.
		 * @param	ms	The milliseconds to convert.
		 * @return	Returns the appropriate time string from milliseconds.
		 */
		public static function ToTimeString(ms:Number):String {
			var s:String = Math.round(Math.floor(ms % 60000)/1000).toString();
			var m:String = Math.floor(ms / 60000).toString();
			return m + ":" + StringUtils.padLeft(s, "0", 2);
		}
		
		/**
		 * Converts the specified milliseconds into the number of hours.
		 * @param	ms	The milliseconds to convert.
		 * @return	Returns the the number of hours the milliseconds contains.
		 */
		public static function ToHours(ms:Number):Number {
			return Math.floor(ms / 3600000);
		}
		
		/**
		 * Converts the specified milliseconds into the number of days.
		 * @param	ms	The milliseconds to convert.
		 * @return	Returns the the number of days the milliseconds contains.
		 */
		public static function ToDays(ms:Number):Number {
			return Math.floor(ms / 86400000);
		}
		
		/**
		 * Converts the specified milliseconds into the number of days as a zero leading string.
		 * @param	ms	The milliseconds to convert.
		 * @return	Returns the the number of days the milliseconds contains as a zero leading string.
		 */
		public static function ToDaysString(ms:Number):String {
			return StringUtils.padLeft(ToDays(ms).toString(), "0", 2);
		}
	}
}